-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
[mypy] Fix type annotations in data_structures/binary_tree
#5518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
l3str4nge
merged 2 commits into
TheAlgorithms:master
from
shermanhui:mypy-fix-data_structures/binary_trees
Oct 22, 2021
Merged
[mypy] Fix type annotations in data_structures/binary_tree
#5518
l3str4nge
merged 2 commits into
TheAlgorithms:master
from
shermanhui:mypy-fix-data_structures/binary_trees
Oct 22, 2021
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Update binary_search_tree `arr` argument to be typed as a list within `find_kth_smallest` function Update return type of `merge_two_binary_trees` as both inputs can be None which means that a None type value can be returned from this function
poyea
approved these changes
Oct 22, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your pull request!🤩Let's make it --strict
? It's not a strict requirement though:
> mypy . --ignore-missing-imports --strict
binary_search_tree.py:7: error: Function is missing a type annotation
binary_search_tree.py:13: error: Function is missing a return type annotation
binary_search_tree.py:22: error: Function is missing a type annotation
binary_search_tree.py:25: error: Function is missing a return type annotation
binary_search_tree.py:31: error: Function is missing a type annotation
binary_search_tree.py:35: error: Call to untyped function "is_right" in typed context
binary_search_tree.py:42: error: Function is missing a type annotation
binary_search_tree.py:45: error: Function is missing a return type annotation
binary_search_tree.py:48: error: Function is missing a type annotation
binary_search_tree.py:52: error: Call to untyped function "Node" in typed context
binary_search_tree.py:53: error: Call to untyped function "empty" in typed context
binary_search_tree.py:72: error: Function is missing a type annotation
binary_search_tree.py:74: error: Call to untyped function "__insert" in typed context
binary_search_tree.py:77: error: Function is missing a type annotation
binary_search_tree.py:78: error: Call to untyped function "empty" in typed context
binary_search_tree.py:87: error: Function is missing a type annotation
binary_search_tree.py:93: error: Call to untyped function "empty" in typed context
binary_search_tree.py:98: error: Function is missing a type annotation
binary_search_tree.py:104: error: Call to untyped function "empty" in typed context
binary_search_tree.py:110: error: Function is missing a type annotation
binary_search_tree.py:111: error: Call to untyped function "search" in typed context
binary_search_tree.py:114: error: Call to untyped function "__reassign_nodes" in typed context
binary_search_tree.py:116: error: Call to untyped function "__reassign_nodes" in typed context
binary_search_tree.py:118: error: Call to untyped function "__reassign_nodes" in typed context
binary_search_tree.py:120: error: Call to untyped function "get_max" in typed context
binary_search_tree.py:123: error: Call to untyped function "remove" in typed context
binary_search_tree.py:128: error: Function is missing a type annotation
binary_search_tree.py:131: error: Call to untyped function "preorder_traverse" in typed context
binary_search_tree.py:132: error: Call to untyped function "preorder_traverse" in typed context
binary_search_tree.py:134: error: Function is missing a type annotation
binary_search_tree.py:140: error: Call to untyped function "preorder_traverse" in typed context
binary_search_tree.py:144: error: Function is missing a return type annotation
binary_search_tree.py:144: error: Missing type parameters for generic type "list"
binary_search_tree.py:148: error: Argument 2 to "inorder" of "BinarySearchTree" has incompatible type "Optional[Any]"; expected "Node"
binary_search_tree.py:150: error: Argument 2 to "inorder" of "BinarySearchTree" has incompatible type "Optional[Any]"; expected "Node"
binary_search_tree.py:154: error: Missing type parameters for generic type "list"
binary_search_tree.py:156: error: Returning Any from function declared to return "int"
binary_search_tree.py:159: error: Function is missing a type annotation
binary_search_tree.py:165: error: Call to untyped function "postorder" in typed context
binary_search_tree.py:169: error: Function is missing a return type annotation
binary_search_tree.py:169: note: Use "-> None" if function does not return a value
binary_search_tree.py:191: error: Call to untyped function "BinarySearchTree" in typed context
binary_search_tree.py:193: error: Call to untyped function "insert" in typed context
binary_search_tree.py:198: error: Call to untyped function "search" in typed context
binary_search_tree.py:203: error: Call to untyped function "search" in typed context
binary_search_tree.py:208: error: Call to untyped function "empty" in typed context
binary_search_tree.py:209: error: Call to untyped function "get_max" in typed context
binary_search_tree.py:210: error: Call to untyped function "get_min" in typed context
binary_search_tree.py:213: error: Call to untyped function "remove" in typed context
Found 48 errors in 1 file (checked 3 source files)
l3str4nge
approved these changes
Oct 22, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fix type annotations in
data_structures/binary_tree/binary_search_tree.py
anddata_structures/binary_tree/merge_two_binary_trees.py
My contribution to fixing the
mypy
errors identified in #4052Update binary_search_tree
arr
argument to be typed as a listwithin
find_kth_smallest
functionUpdate return type of
merge_two_binary_trees
as both inputs canbe None which means that a None type value can be returned from
this function
Checklist:
Fixes: #{$ISSUE_NO}
.